package io.gitee.guoguoleo.chain;

import io.gitee.guoguoleo.model.FieldList;
import io.gitee.guoguoleo.utils.FieldUtil;
import io.gitee.guoguoleo.wrapper.Wrapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.concurrent.CopyOnWriteArrayList;

public class Chain<T> extends Wrapper<T> {

    protected Class<T> clazz;
    protected JdbcTemplate jdbcTemplate;
    protected FieldList fieldList;

    public Chain(Class<T> clazz, JdbcTemplate jdbcTemplate) {
        this.clazz = clazz;
        this.jdbcTemplate = jdbcTemplate;
        //初始化字段列
        this.fieldList = FieldUtil.getAllField(clazz);

        this.andFlag = true;
        this.orFlag = false;

        this.whereExpressionList = new CopyOnWriteArrayList<>();
        this.orderByElementList = new CopyOnWriteArrayList<>();

        this.selectColumnList = new CopyOnWriteArrayList<>();
        this.excludeSelectColumnList = new CopyOnWriteArrayList<>();
    }

}
